{{include file="public/header.php"/>}}

<ol class="breadcrumb">
	<li>
		<span class="glyphicon glyphicon-home"></span>
		<a href="{{U('Cms/Index/welcome')}}">首页</a>
	</li>
	<li>模型字段</li>
</ol>
<div id="page-wrapper">
	<div class="row">
		<div class="col-lg-12">
			<div class="alert alert-success" style="border:solid 1px #27ae60;">
				<strong>注意!</strong>
				随意修改菜单将影响后台功能<br/>
				随意修改菜单将影响后台功能
			</div>
		</div>
	</div>
	<div class="row">
		<div class="col-lg-12">
			<div class="main-box clearfix">
				<div class="main-box-body clearfix">
					<div class="table-responsive">
						<table class="table table-striped table-hover">
							<thead>
								<tr>
									<th><span>排序</span></th>
									<th><span>fid</span></th>
									<th><span>描述</span></th>
									<th><span>字段名</span></th>
									<th><span>表名</span></th>
									<th><span>类型</span></th>
									<th><span>系统</span></th>
									<th><span>必填</span></th>
									<th><span>搜索</span></th>
									<th><span>投稿</span></th>
									<th><span>操作</span></th>
								</tr>
							</thead>
							<tbody>
								{{foreach from="$data" key="$k" value="$v"}}
								<tr>
									<td width="80">
										<input type="text" onblur="fieldsort(this)" fid="{{$v['fid']}}" value="{{$v['fieldsort']}}" name="fieldsort" class="form-control input-sm">
									</td>
									<td>{{$v['fid']}}</td>
									<td>{{$v['title']}}</td>
									<td>{{$v['field_name']}}</td>
									<td>{{$v['table_name']}}</td>
									<td>{{$v['field_type']}}</td>
									<td>{{$v['is_system']?'√':'×';}}</td>
									<td>{{$v['required']?'√':'×';}}</td>
									<td>{{$v['issearch']?'√':'×';}}</td>
									<td>{{$v['isadd']?'√':'×';}}</td>
									<td width="100">
										<div class="btn-group">
											<button type="button" class="btn btn-xs btn-default dropdown-toggle"
											data-toggle="dropdown">
											操作 <span class="caret"></span>
										</button>
										<ul class="dropdown-menu" role="menu">
											<li>
												<a href="/cms/field/{{$v['fid']}}/edit">
													<span class=" glyphicon glyphicon-edit"></span> 编辑
												</a>
											</li>
											<li>
												<a href="javascript:remove({{$v['fid']}});">
													<span class="glyphicon glyphicon-trash"></span> 删除
												</a>
											</li>
										</ul>
									</div>
								</td>
							</tr>
							{{/foreach}}
						</tbody>
					</table>
					<a href="/cms/field/create?mid={{$_GET['mid']}}" class="btn btn-default btn-xm">新增字段</a>
				</div>
			</div>
		</div>
	</div>
</div>
</div>

{{include file="public/footer.php"/}}

<script>
	function fieldsort(obj)
	{
		fid = $(obj).attr('fid');
		fieldsort = $(obj).val();
		$.get('{{U('fieldsort')}}',{fid:fid,fieldsort:fieldsort},function(result){
			if (result.code == 0) {
				dialog('更新排序成功，请刷新页面', 'success', 1000, function () {

				});
			}
		},'json');
	}

	//删除菜单
	function remove(fid) {
		if(confirm('确定删除吗'))
		{
			$.ajax({
				url: "/cms/field/"+fid+'?mid={{$_GET['mid']}}',
				type: 'DELETE',
				dataType: 'JSON',
				success: function (result) {
					if (result.code == 0) {
						dialog(result.message, 'success', 1000, function () {
							window.location.reload(true);
						});
					}
					else {
						dialog(result.message, 'error', 1000);
					}
				}
			})
		}
	}
</script>